#include "rtda/heap/cp_interface_methodref.h"
#include "classfile/class_file.hpp"
#include "rtda/heap/method.h"
#include <memory>

namespace jvm {
namespace heap {

InterfaceMethodRef::InterfaceMethodRef(std::shared_ptr<ConstantPool> pCp, 
    const std::shared_ptr<classfile::ConstantMemberrefInfo> pMemberrefInfo) 
    : MemberRef(pCp) {
    copyMemberRefInfo(pMemberrefInfo);
}

std::shared_ptr<InterfaceMethodRef> InterfaceMethodRef::newInterfaceMethodRef(std::shared_ptr<ConstantPool> pCp, 
    const std::shared_ptr<classfile::ConstantInterfaceMethodRefInfo> pInterfaceMethodrefInfo) {
    return std::make_shared<InterfaceMethodRef>(pCp, pInterfaceMethodrefInfo);
}

std::shared_ptr<Method> InterfaceMethodRef::resolvedInterfaceMethod() {
    if (!m_pMethod) {
        resolveInterfaceMethodRef();
    }
    return m_pMethod;
}

void InterfaceMethodRef::resolveInterfaceMethodRef() {
    // TODO: Implement interface method resolution according to JVMS 5.4.3.4
    // Class* pClass = resolvedClass();
    // ...
}

} // namespace heap
} // namespace jvm